// custom-tab-bar/index.js
const app=getApp();
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },
    attached(){
        this.setData({
            currentIndex:app.globalData.tabIndex
        })
    },

    /**
     * 组件的初始数据
     */
    data: {
        currentIndex:1,
        list:[
          {
            "index":1,
            "text": "推荐",
            "pagePath": "/pages/recommend/recommend"
          },
          {
            "index":2,
            "text": "频道",
            "pagePath": "/pages/channel/channel"
          },
          {
            "index":3,
            "text": "个人中心",
            "pagePath": "/pages/user/user"
          }
        ]
    },

    /**
     * 组件的方法列表
     */
    methods: {
        jump(event){
            let id=event.target.dataset.id;
            let path=event.target.dataset.path;
            wx.switchTab({
              url: path,
            });
            app.globalData.tabIndex=id;
          }
    }
})
